/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.general.bc;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.cip.esymons.general.be.ComiteLocal;

/**
 *
 * @author OscarA
 */
@Stateless
public class ComiteLocalFacade implements ComiteLocalFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(ComiteLocal comiteLocal) {
        em.persist(comiteLocal);
    }

    public void edit(ComiteLocal comiteLocal) {
        em.merge(comiteLocal);
    }

    public void remove(ComiteLocal comiteLocal) {
        ComiteLocal aux = em.merge(comiteLocal);
        em.remove(aux);
    }

    public ComiteLocal find(Object id) {
        return em.find(ComiteLocal.class, id);
    }

    public List<ComiteLocal> findAll() {
        return em.createQuery("select object(o) from ComiteLocal as o order by o.cloNombre").getResultList();
    }

    public List<ComiteLocal> listarxConsejoDepartamental(int id) {
         return em.createQuery("select object(o) from ComiteLocal as o where o.cdeCodigo.cdeCodigo=?1").setParameter(1, id).getResultList();
    }

}
